package cn.gok.mybatisplus.handler;

import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @ClassName MetaObjectHandler
 * @Description TODO
 * @Author HP
 * @Date 10:25 2022/7/20
 * @Version 1.0
 **/
@Slf4j
@Component
public class MetaObjectHandler implements com.baomidou.mybatisplus.core.handlers.MetaObjectHandler {

    // 插入时的填充策略
    @Override
    public void insertFill(MetaObject metaObject) { log.info("start insert fill ");
        this.setFieldValByName("createTime",new Date(),metaObject);
        this.setFieldValByName("updateTime",new Date(),metaObject);
    }
    // 更新时的填充策略
    @Override
    public void updateFill(MetaObject metaObject) { log.info("start update fill ");
        this.setFieldValByName("updateTime",new Date(),metaObject);
    }
}
